<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改售后平台自购配件')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <link href="../static/css/bootstrap-select.min.css" th:href="@{/css/bootstrap-select.min.css}" rel="stylesheet"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-afterParts-edit" th:object="${zsyhAfterParts}">
            <input name="id" th:field="*{id}" type="hidden">
            <input name="partsState" th:field="*{partsState}" id="partsState" type="hidden" value="1">
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">厂家信息Id：</label>
                <div class="col-sm-8">
                    <input name="factoryId" th:field="*{factoryId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">产品Id：</label>
                <div class="col-sm-8">
                    <input name="partsId" th:field="*{partsId}" class="form-control" type="text">
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">配件名称：</label>
                <div class="col-sm-8">
                    <input name="partsName" th:field="*{partsName}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">配件型号：</label>
                <div class="col-sm-8">
                    <input name="partsAttribute" th:field="*{partsAttribute}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">配件图片：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="partsImages" th:field="*{partsImages}" readonly>
                    <div class="file-loading">
                        <input class="form-control file-upload" id="partsImages" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">配件描述：</label>
                <div class="col-sm-8">
                    <textarea name="partsRemarks" class="form-control" readonly>[[*{partsRemarks}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">厂家定价：</label>
                <div class="col-sm-8">
                    <input name="partsPriceFactory" th:field="*{partsPriceFactory}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">师傅定价：</label>
                <div class="col-sm-8">
                    <input name="partsPriceRepair" th:field="*{partsPriceRepair}" class="form-control" type="text" required>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">状态 0未审核 1已审核：</label>
                <div class="col-sm-8">
                    <select name="partsState" class="form-control m-b" th:with="type=${@dict.getType('zsyh_review')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{partsState}"></option>
                    </select>
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script src="../static/js/bootstrap-select.min.js" th:src="@{/js/bootstrap-select.min.js}"></script>
    <script th:inline="javascript">
        var prefix = ctx + "zsyh/afterParts";
        $("#form-afterParts-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $("#partsState").val("1");
                $.operate.save(prefix + "/edit", $('#form-afterParts-edit').serialize());
            }
        }

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/uploadOSS',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                showRemove: false,/*是否显示移除按钮*/
                showUpload: false,/*是否显示上传按钮*/
                showBrowse: false,/*是否显示浏览按钮,选择按钮*/
                showCaption: false, /*是否显示被选文件的简介*/
                autoReplace: true,
                layoutTemplates: {
                    actionDelete:'',
                    actionUpload:''
                } /*去掉缩略图上的删除和上传按钮*/
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            }).on("filebatchselected", function(event, files) {
                $(this).fileinput("upload");
            })
            $(this).fileinput('_initFileActions');
        });

    </script>
</body>
</html>